package org.apache.lucene.index;

import java.io.IOException;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.index.DocumentsWriter.IndexingChain;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.LockObtainFailedException;


public class IndexProviderIndexWriter extends GAEStandardIndexWriter {

	private final CloseCallback closeCallback;

	public IndexProviderIndexWriter(Directory d, Analyzer a,
			boolean create, IndexDeletionPolicy deletionPolicy,
			MaxFieldLength mfl, IndexingChain indexingChain,
			IndexCommit commit, CloseCallback closeCallback) throws CorruptIndexException,
			LockObtainFailedException, IOException {
		super(d, a, create, deletionPolicy, mfl, indexingChain, commit);
		this.closeCallback = closeCallback;
	}

	public IndexProviderIndexWriter(Directory d, Analyzer a,
			boolean create, IndexDeletionPolicy deletionPolicy,
			MaxFieldLength mfl, CloseCallback closeCallback) throws CorruptIndexException,
			LockObtainFailedException, IOException {
		super(d, a, create, deletionPolicy, mfl);
		this.closeCallback = closeCallback;
	}

	public IndexProviderIndexWriter(Directory d, Analyzer a,
			boolean create, MaxFieldLength mfl, CloseCallback closeCallback)
			throws CorruptIndexException, LockObtainFailedException,
			IOException {
		super(d, a, create, mfl);
		this.closeCallback = closeCallback;
	}

	public IndexProviderIndexWriter(Directory d, Analyzer a,
			IndexDeletionPolicy deletionPolicy, MaxFieldLength mfl,
			IndexCommit commit, CloseCallback closeCallback) throws CorruptIndexException,
			LockObtainFailedException, IOException {
		super(d, a, deletionPolicy, mfl, commit);
		this.closeCallback = closeCallback;
	}

	public IndexProviderIndexWriter(Directory d, Analyzer a,
			IndexDeletionPolicy deletionPolicy, MaxFieldLength mfl, CloseCallback closeCallback)
			throws CorruptIndexException, LockObtainFailedException,
			IOException {
		super(d, a, deletionPolicy, mfl);
		this.closeCallback = closeCallback;
	}

	public IndexProviderIndexWriter(Directory d, Analyzer a,
			MaxFieldLength mfl, CloseCallback closeCallback) throws CorruptIndexException,
			LockObtainFailedException, IOException {
		super(d, a, mfl);
		this.closeCallback = closeCallback;
	}
	
	@Override
	public void close(boolean waitForMerges) throws CorruptIndexException,
			IOException {
		super.close(waitForMerges);
		if (closeCallback != null)
			closeCallback.closed();
	}
}